﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using QLKS.Templates;
using System.Data;
//using DevExpress.Xpf.Printing;
//using DevExpress.XtraReports.UI;

namespace QLKS.Views
{
    /// <summary>
    /// Interaction logic for frmBCDoanhThuTheoLoaiPhong.xaml
    /// </summary>
    public partial class frmBCDoanhThuTheoLoaiPhong : FormTrans
    {
        int nam = 0;
        int ky = 0;
        DataSet ds = new DataSet();
        public frmBCDoanhThuTheoLoaiPhong(int nam, int ky)
        {
            InitializeComponent();
            this.nam = nam;
            this.ky = ky;
        }

        private void FormTrans_Loaded(object sender, RoutedEventArgs e)
        {
            ds = ViewModels.BaoCaoViewModel.GetBaoCaoDoanhThuTheoLoaiPhong(nam, ky);
            mainContent.StringBrowse = "ftag:ftag:0:IV;malp:malp:0:IV;stt:Stt:30:IV;tenlp:Tên loại phòng:120:F;tongtien:Tổng tiền:100;tongtiennt:Tổng tiền n.tệ:100;tyle:Tỷ lệ %:70;ngaythue:Ngày thuê:80;ngaytra:Ngày trả:80;tenkh:Tên Khách hàng:200;diachi:Địa chỉ:200";
            mainContent.TableSource = ds.Tables[0];
            mainContent.AddSummaryValue(new string[] { "tenlp", "tongtien", "tongtiennt" }, new string[] { "Tổng cộng:", ds.Tables[1].Rows[0]["tongtienVND"].ToString(), ds.Tables[1].Rows[0]["tongtienUSD"].ToString() });
            mainContent.SetRowColorByTag("ftag", "0");
            mainContent.F5 += new ucDmTemplate.GridKeyUp_F5(PressKey_F5);//Chi Tiết
            mainContent.F9 += new ucDmTemplate.GridKeyUp_F9(PressKey_F9);
        }

        void PressKey_F5(object sender, EventArgs e)
        {
            DataTable tb = mainContent.CurentRow;
            if (tb == null)
                return;
            (new frmBCChiTietDoanhThuTheoLoaiPhong(nam,ky,int.Parse(tb.Rows[0]["malp"].ToString()))).Show();
        }
        void PressKey_F9(object sender, EventArgs e)
        {
            frmPrinter frm = new frmPrinter("BCDoanhThuTheoLoaiPhong", ds);
            frm.ShowDialog();
        }
    }
}
